<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div>

    <script>
      //targetNum为最终数值，delay为效果持续时间
      function numscroll(elementID, targetNum, delay) {
        let a = document.getElementById(elementID);
        let timmerA = setInterval(function () {
          if (a.innerText != targetNum) {
            let num = Number(a.innerText);
            num += Number((targetNum / delay / 10).toFixed(0)); //若有小数需求可自行修改此行
            if (num < targetNum) {
              //针对有余数除不尽
              a.innerText = num;
            } else {
              a.innerText = targetNum;
            }
          } else {
            clearInterval(timmerA);
          }
        }, 100);
      }

      numscroll("one", 98501, 2);
      numscroll("two", 20, 2);
      numscroll("three", 15000, 2);
    </script>
  </body>
</html>
